import datetime
import pandas as pd
__author__ = 'LuckyHhy'


def get_format_time(basetime, dformat='%Y-%m-%d %H:%M:%S'):
    return datetime.datetime.strftime(basetime, dformat)


def get_format_day(basetime, dformat='%Y-%m-%d'):
    return datetime.datetime.strftime(basetime, dformat)



def get_today(dformat='%Y-%m-%d'):
    return datetime.datetime.now().strftime(dformat)



def get_now(dformat='%Y-%m-%d %H:%M:%S'):
    return datetime.datetime.now().strftime(dformat)



def get_year():
    return datetime.datetime.now().strftime('%Y')



def get_month():
    return datetime.datetime.now().strftime('%m')



def get_day():
    return datetime.datetime.now().strftime('%d')



def get_delt_days(starttime, endtime):
    return (endtime - starttime).days



def get_delt_secs(starttime, endtime):
    return (endtime - starttime).microseconds



def get_add_time(basetime, days=0, hours=0, minutes=0, seconds=0):
    return basetime + datetime.timedelta(days=days, hours=hours, minutes=minutes, seconds=seconds)



def get_minus_time(basetime, days=0, hours=0, minutes=0, seconds=0):
    return basetime - datetime.timedelta(days=days, hours=hours, minutes=minutes, seconds=seconds)



def get_date_list(startdate, enddate, freq='1D', dformat='%Y-%m-%d'):
    tm_rng = pd.date_range(startdate, enddate, freq=freq)
    return [x.strftime(dformat) for x in tm_rng]